package com.example.demo.mapper;

import com.example.demo.mapper.entity.Area;
import com.example.demo.mapper.entity.City;
import com.example.demo.mapper.entity.Province;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author Lucy
 * @create 2024-02-20 14:54
 */
@Mapper
@Repository
public interface RegionMapper {
    @Select("SELECT * FROM hat_province")
    List<Province> allProvince();

    @Select("SELECT * FROM hat_city WHERE father = #{father} ORDER BY city")
    List<City> findCityByFather(String father);

    @Select("SELECT * FROM hat_area WHERE father = #{father} ORDER BY area")
    List<Area> findAreaByFather(String father);
    @Select("SELECT province FROM hat_province WHERE province_id = #{provinceId}")
    String selectProvinceNameById(String provinceId);
    @Select("SELECT city FROM hat_city WHERE city_id = #{cityId}")
    String selectCityNameById(String cityId);
    @Select("SELECT area FROM hat_area WHERE area_id = #{areaId}")
    String selectAreaNameById(String areaId);
}
